package com.project.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ManBean;
import com.project.mapper.IManMapper;
import com.project.service.IManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

/**
 * @author lyl
 * description:
 */
@Service
@Transactional
public class ManServiceImpl implements IManService {
    @Autowired
    private IManMapper iManMapper;

    @Override
    public void add(ManBean manBean) {
        iManMapper.add(manBean);
    }

    @Override
    public PageInfo<ManBean> findAll(int pageNum) {
        PageHelper.startPage(pageNum, 3);
        PageInfo<ManBean> pageInfo = PageInfo.of(iManMapper.findAll());
        return pageInfo;
    }

    @Override
    public void del(int id) {
        iManMapper.del(id);
    }

    @Override
    public void alt(int manId, LocalDate birthday) {
        iManMapper.alt(manId, birthday);
    }

    @Override
    public ManBean findOne(int manId) {
        return iManMapper.findOne(manId);
    }
}
